﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp;
using Abp.Authorization.Users;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Abp.Extensions;
using Microsoft.AspNet.Identity;

namespace RMM.Core.Entity.Users
{
    [Table("RMM_User")]
    public class User : AbpUser<User>
    {
        public const string DefaultPassword = "123456";
        public const string PasswordHasher = "123456";


        public static string CreateRandomPassword()
        {
            return Guid.NewGuid().ToString("N").Truncate(16);
        }

        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public override long Id { get => base.Id; set => base.Id = value; }


        /// <summary>
        /// 0 男 1女
        /// </summary>
        public int Sex { get; set; }
        /// <summary>
        /// 类型 1:普通用户 
        /// </summary>
        public int UserType { get; set; }
        
        /// <summary>
        /// 用户等级ID
        /// </summary>
        public int GradeId { get; set; }

        /// <summary>
        /// 推荐人id
        /// </summary>
        public long ReferralUserId { get; set; }

        /// <summary>
        /// 用户状态(正常:1 已删除:7)
        /// </summary>
        public int Status { get; set; }

        public string Mobile { get; set; }


        public string Remark { get; set; }

        public string OpenId { get; set; }

        public string UnionID { get; set; }

        public string SessionId { get; set; }

        public string SessionEndTime { get; set; }

        public string UserHead { get; set; }

        public string UserBindName { get; set; }


        public string WeiXinNumer { get; set; }


        /// <summary>
        /// 身份证
        /// </summary>
        public string CardID { get; set; }

        public string Address { get; set; }

        public string Email { get; set; }

        ///// <summary>
        ///// 如果是计师，表示店家id
        ///// </summary>
        //public long ShopId { get; set; }
        
        ///// <summary>
        ///// 如果是技师，表示擅长项目
        ///// </summary>
        //public string GoodAt { get; set; }
        


        public static User CreateAdminUser(string password,string Email, int tenantId = 1)
        {
            return new User
            {
                TenantId = tenantId,
                NickName = AdminUserName,
                UserName = AdminUserName,
                Name = AdminUserName,
                Surname = AdminUserName,
                EmailAddress = Email,
                Email = Email,
                Password = new PasswordHasher().HashPassword(password)
            };
        }

        /// <summary>
        /// 昵称
        /// </summary>
        [StringLength(255)]
        public virtual string NickName { get; set; }
    }
}
